package com.yzh.opp4.teacher;

/**
 * 食堂类
 *
 * 多态的前提条件
 * 1.继承 public class Chinese extends Programmer
 * 2.重写 public void eat() {}
 * 3.将子类对象赋给父类的引用变量 Programmer pro = new Italian();
 *
 * 编译的类型 = 运行时类型
 *
 * pro.eat()
 * 执行的不是父类Programmer的，是子类重写的Italian
 */
public class Canteen {
    /*
    public static void  showEat(Chinese ch){
        ch.eat();
    }
    public static void  showEat(English en){
        en.eat();
    }
    public static void  showEat(Italian  it){
        it.eat();
    }

     */
    public static void showEat(Programmer programmer){
        programmer.eat();
    }

    public static void main(String[] args) {
        Chinese ch = new Chinese();
        showEat(ch);

        English en = new English();
        showEat(en);

        Italian it = new Italian();
        showEat(it);


       Programmer pro = new Italian();
        showEat(pro);
    }



}
